// eslint-disable-next-line no-unused-vars
const proxy = require('http-proxy-middleware');
const bodyParser = require('body-parser');
// const {localtest} = require('./localtest');

module.exports = app => {
    app.use(bodyParser.urlencoded({extended: true}));
    app.use('/api/v1/users', require('./users'));
    app.use('/parts/api/v1/ui', require('./ui'));
    // 禁止socket连接
    // app.use('/api/v1/notifications', (req, res) => {
    //     res.sendStatus(403);
    // });
    // app.use('/api/v1/notifyChannel', (req, res) => {
    //     res.sendStatus(403);
    // });
    // app.use('/sales/api/v1/areas', require('./area'));
    // app.use('/parts/api/v1/partSaleOrders', require('./partSaleOrder'));
    // app.use('/parts/api/v1/dealers', require('./dealer'));
    // app.use('/parts/api/v1/subDealers', require('./subDealer'));
    // app.use('/parts/api/v1/areaTileds', require('./region'));
    // app.use('/parts/api/v1/marketDepartments', require('./marketDepartment'));
    // app.use('/parts/api/v1/areas', require('./area'));
    // app.use('/parts/api/v1/dealerPartWarehouses', require('./dealerPartWarehouse'));
    // app.use('/parts/api/v1/customsClearances', require('./customsClearance'));
    // app.use('/api/v1/files', require('./file'));
    // app.use('/parts/api/v1/dealerPartAccounts', require('./dealerPartAccount'));
    // app.use('/parts/api/v1/partSaleOrderTypes', require('./partSaleOrderType'));
    // app.use('/parts/api/v1/accessoryOrders', require('./accessoryOrder'));
    // app.use('/parts/api/v1/dealerRaisingRateLinks', require('./dealerRaisingRateLink'));
    // app.use('/parts/api/v1/partSaleOrderTypes', require('./partSaleOrderType'));
    // app.use('/parts/api/v1/dealerPartArriveClaims', require('./dealerPartArriveClaim'));
    // app.use('/parts/api/v1/partWarehouses', require('./partWarehouse'));
    // app.use('/parts/api/v1/parts', require('./parts'));
    // app.use('/parts/api/v1/tradeMethods', require('./tradeMethod'));
    // app.use('/parts/api/v1/brands', require('./brand'));
    // app.use('/parts/api/v1/personnels', require('./personnel'));
    // app.use('/parts/api/v1/partOrderPlans', require('./partOrderPlan'));
    // app.use('/parts/api/v1/workingDaies', require('./workingDay'));
    // app.use('/parts/api/v1/partStocks', require('./partStock'));
    // app.use('/parts/api/v1/banks', require('./bank'));
    // app.use('/parts/api/v1/exchangeRates', require('./exchangeRate'));
    // app.use('/parts/api/v1/carriers', require('./carrier'));
    // app.use('/parts/api/v1/lcCreditManagements', require('./lcCreditManagement'));
    // app.use('/parts/api/v1/stockRequirements', require('./stockRequirement'));
    // app.use('/parts/api/v1/partShipOrders', require('./partShipOrders'));
    // app.use('/parts/api/v1/partShipOrders', require('./partShipOrders'));
    // app.use('/parts/api/v1/deliveryOrders', require('./deliveryOrder'));
    // app.use('/parts/api/v1/pickings', require('./picking'));
    // app.use('/parts/api/v1/partInvoices', require('./partInvoice'));
    // app.use('/parts/api/v1/partShipments', require('./partShipment'));
    // app.use('/parts/api/v1/shipmentConfirms', require('./shipmentConfirm'));
    // app.use('/parts/api/v1/packingLists', require('./packingList'));
    // app.use('/parts/api/v1/partShipNotices', require('./partShipNotice'));
    // app.use('/parts/api/v1/packingListCabinetApplies', require('./packingListCabinetApply'));
    // app.use('/parts/api/v1/partBackOrders', require('./partBackOrder'));
    // app.use('/parts/api/v1/partClaims', require('./partClaim'));
    // app.use('/parts/api/v1/rebateFees', require('./rebateFee'));
    // app.use('/parts/api/v1/partShipmentSignFors', require('./partShipmentSignFor'));
    // app.use('/parts/api/v1/partInvoiceExports', require('./partInvoiceExport'));
    // app.use('/parts/api/v1/partClaimDecisions', require('./partClaimDecision'));
    // app.use('/parts/api/v1/partClaimReports', require('./partClaimReport'));
    // app.use('/parts/api/v1/partClaimCacus', require('./partClaimCacu'));
    // app.use('/parts/api/v1/partShipmentDelivers', require('./partShipmentDeliver'));
    // app.use('/parts/api/v1/partInvoices', require('./partInvoicesInfo'));
    // app.use('/parts/api/v1/partOrderPis', require('./partOrderPi'));
    // app.use('/parts/api/v1/parts', require('./sapToParts'));
    // app.use('/parts/api/v1/partSalesPrices', require('./partSalesPrice'));
    // app.use('/parts/api/v1/dutyUnits', require('./dutyUnit'));
    // app.use('/parts/api/v1/orderUnmetReasons', require('./orderUnmetReasons'));
    // app.use('/parts/api/v1/partStockDealers', require('./partStockDealer'));
    // app.use('/parts/api/v1/orderSatisfactionRuleInformations', require('./orderSatisfactionRuleInformations'));
    // app.use('/parts/api/v1/banks', require('./banks'));
    // app.use('/parts/api/v1/orderSatisfactionRuleInformations', require('./orderSatisfactionRuleInformations'));
    // app.use('/parts/api/v1/banks', require('./banks'));
    // app.use('/parts/api/v1/accountQuerys', require('./accountQuery'));
    // app.use('/parts/api/v1/returnBalanceQuerys', require('./returnBalanceQuery'));
    // app.use('/parts/api/v1/returnDetailedQuerys', require('./returnDetailedQuery'));
    // app.use('/parts/api/v1/hsCodes', require('./hsCode'));
    // app.use('/parts/api/v1/packingListTracks', require('./packingListTrack'));
    // app.use('/parts/api/v1/partSaleOrderTracks', require('./partSaleOrderTrack'));
    // app.use('/parts/api/v1/deliveryOrderTracks', require('./deliveryOrderTrack'));
    // app.use('/parts/api/v1/dealerParts', require('./dealerPart'));
    // app.use('/parts/api/v1/packingListDetails', require('./packingListDetails'));
    // app.use('/parts/api/v1/partInvoiceDetails', require('./partInvoiceDetails'));
    // app.use('/parts/api/v1/deliveryOrderHis', require('./deliveryOrderHis'));
    // app.use('/parts/api/v1/partSaleOrderHises', require('./partSaleOrderHises'));
    // app.use('/parts/api/v1/partClaimHises', require('./partClaimHises'));
    // app.use('/parts/api/v1/partOrderPiHistories', require('./partOrderPiHistories'));
    // app.use('/parts/api/v1/partInvoiceTracks', require('./partInvoiceTrack'));
    // app.use('/parts/api/v1/notices', require('./notices'));
    // app.use('/parts/api/v1/noticePrograms', require('./noticePrograms'));
    // app.use('/parts/api/v1/dashboards', require('./dashboards'));
    // app.use('/parts/api/v1/partDataModifyLogs', require('./partDataModifyLogs'));
    // app.use('/parts/api/v1/dealerPartResources', require('./dealerPartResource'));
    // app.use('/parts/api/v1/partStockReports', require('./partStockReport'));
    // app.use('/parts/api/v1/planComsatRates', require('./planComsatRates'));
    // app.use('/parts/api/v1/partOrderSupplies', require('./partOrderSupply'));
    // app.use('/parts/api/v1/partOrderRateShipmentDaies', require('./partOrderRateShipmentDay'));
    // app.use('/parts/api/v1/partOrderSatisfyRates', require('./partOrderSatisfyRates'));
    // app.use('/parts/api/v1/partClaimReportForms', require('./partClaimReportForms'));
    // app.use('/parts/api/v1/backOrders', require('./backOrder'));
    // app.use('/parts/api/v1/partStockMonths', require('./partStockMonth'));
    // app.use('/parts/api/v1/partShipAppointRates', require('./partShipAppointRates'));

    // 代理远程服务器
    app.use([
        '/parts/api/v1',
        '/static/config.json',
        '/login',
        '/api/v1/login',
        '/api/v1/users'
    ], proxy({
        target: 'https://dev.chery-intl.sdt-int.com/',
        changeOrigin: true,
    }));
};
